# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-pry
pkgver=0.14.2
_commit=24f6190e42f24979886cf6d974b70bd7638fda46
pkgrel=2
pkgdesc='A runtime developer console and IRB alternative with powerful introspection capabilities'
arch=(any)
url='http://pry.github.io/'
license=(MIT)
depends=(ruby-coderay ruby-method_source)
makedepends=(git)
checkdepends=(ruby-rake ruby-rspec ruby-yard)
options=(!emptydirs)
source=(git+https://github.com/pry/pry.git#commit=$_commit)
sha256sums=('SKIP')

prepare() {
  cd pry
  sed -i -r -e 's|~>|>=|' pry.gemspec
}

build() {
  local _gemdir="$(gem env gemdir)"
  cd pry
  gem build pry.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    pry-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd pry
  EDITOR=vim TERM=screen-256color GEM_HOME="tmp_install/$_gemdir" rake
}

package() {
  cd pry
  cp -a tmp_install/* "$pkgdir"/
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
